Imports System.IO
Module Module1

    Sub Main(ByVal args As String())
        Dim size As Long = GetFolderSize(args(0))
        size /= 1024.0 * 1024.0
        System.Console.WriteLine("Folder {0} 's size = {1} Mbytes", args(0), size)
    End Sub

    Function GetFolderSize(ByVal folder As String) As Long
        Dim di As New DirectoryInfo(folder)

        ' count the files
        For Each fi As FileInfo In di.GetFiles()
            GetFolderSize += fi.Length
            'Console.WriteLine("{0}, {1}, {2}", fi.Name, fi.LastWriteTime, fi.Length)
        Next

        ' recurse for the subdirectories
        For Each subFolder As DirectoryInfo In di.GetDirectories()
            GetFolderSize += GetFolderSize(subFolder.FullName)
            'Console.WriteLine("{0}, {1}, {2}", subFolder.FullName, subFolder.LastWriteTime, GetFolderSize)
        Next
    End Function
End Module
